﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.User.AllChildModel>" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    查看用户
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div>
<% Html.BeginForm(); %>
        <table class="table" width="100%">
            <tr>
                <th colspan="4" align="left">&nbsp;&nbsp;搜索条件</th>
            </tr>
            <tr>
                <td>
                    <%=Html.LabelFor(p => p.Where.ChildName)%>
                    <%= Html.TextBoxFor(p => p.Where.ChildName, new { @class = "text100" })%>
                </td>
                <td>
                    <%=Html.LabelFor(p => p.Where.StartTime)%>：从
                    <%=Html.TextBoxFor(p => p.Where.StartTime, new { @class = "text100", onClick = "WdatePicker()" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.StartTime) %>
                </td>
                <td>
                    到
                    <%= Html.TextBoxFor(p => p.Where.EndTime, new { @class = "text100", onClick = "WdatePicker()" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.EndTime) %>
                </td>
                <td rowspan='2'>
                    <input id="btnSearch" type="submit" value="查找" />
                </td>
            </tr>
            <tr>
                <td>
                    <label>
                        当前站点共<%=ViewData["AllCount"] %>个用户，其中代理<%=ViewData["SurrogateCount"]%>个，会员<%=(int)ViewData["AllCount"] - (int)ViewData["SurrogateCount"]%>个
                    </label>
                </td>
                <td>
                    <%=Html.LabelFor(p => p.Where.MinMoney)%>：从
                    <%=Html.TextBoxFor(p => p.Where.MinMoney, new { @class = "text100" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.MinMoney) %>
                </td>
                <td>
                    到
                    <%=Html.TextBoxFor(p => p.Where.MaxMoney, new { @class = "text100" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.MaxMoney) %>
                </td>
            </tr>
        </table>
        <%=Html.Hidden("PageInfo.PageCount",Model.PageInfo.PageCount) %>
 <% Html.EndForm(); %>
    </div>
<div>
    <h4>所属:
    <%
        if (Model.Parents != null)
        {
            var user = Model.Parents.FirstOrDefault(p => p.CommandID ==null);
            while (user != null)
            {
                %><%=Html.ActionLink(user.LoginName+(Model.UserID==user.Uid?string.Format("({0})",Model.ChildsCount):""), "AllUser", new { UserID = user.Uid })%>
                &nbsp;→&nbsp;<%
                user = Model.Parents.FirstOrDefault(p => p.CommandID == user.Uid);
            }
        }
        %>
    </h4>
</div>
<div>
    <table class="table manage_AllUser_Table" width="100%">
        <tr>
            <th>用户名</th><th>类型</th>
            <th style=" width:50px;">
                <label onclick="lbl_OrderBy_Click('Balance','<%=!(Model.OrderByBalanceASC??true)%>')" style="cursor:pointer; border-bottom:1px solid;">
                    余额<%=Model.OrderByBalanceASC.HasValue ?(Model.OrderByBalanceASC.Value? "↑" : "↓"):""%></label>
            </th>
            <th>
                <label onclick="lbl_OrderBy_Click('RegestTime','<%=!(Model.OrderByRegestTimeASC??true)%>')" style="cursor:pointer; border-bottom:1px solid;">
                    注册时间<%=Model.OrderByRegestTimeASC.HasValue ?Model.OrderByRegestTimeASC.Value?"↑" : "↓":""%></label>
            </th>
            <th>最后登录时间</th>
            <th>在线状态</th><th>方案</th><th>账变</th><th>更改类型</th><th>详情</th>
        </tr>
        <% var i = 0;
           var returnUrl = Url.Action("AllUser", "User", Url.Route(new {Model.OrderByBalanceASC,Model.OrderByRegestTimeASC,Model.PageInfo,Model.UserID,Model.Where,returnUrl=Request["returnUrl"] }));
            foreach (var item in Model.Childs)
	    {%>
            <tr <%=i++%2==1?"class='supersede'":"" %>>
                <td><%= item.Type == (short)UserType.Surrogate ? Html.ActionLink(item.ChildName + (Model.UserID == item.Uid ? string.Format("({0})", Model.ChildsCount) : ""), "AllUser", new { page = 1, userID = item.Uid }, new { @class="a_blue"}) : Html.Label(item.ChildName)%></td>
                <td id='td_<%=i %>'><%=Html.Label(((UserType)item.Type).GetName()) %></td>
                <td><%=item.Balance.ToString("F2") %></td>
                <td><label title='<%=string.Format("{0:yyyy-MM-dd HH:mm:ss}",item.RegistTime) %>'><%=string.Format("{0:yyyy-MM-dd}",item.RegistTime) %></label></td>
                <td><label title='<%=string.Format("{0:yyyy-MM-dd HH:mm:ss}",item.LastLoginTime) %>'><%=string.Format("{0:MM-dd HH:mm}",item.LastLoginTime) %></label></td>
                <td><%= item.OnlineState.GetName() %></td>
                <td><%=Html.ActionLink("查看明细", "Index", "Scheme", Url.Route(new { Serch = new { UserName = item.ChildName }, ReturnUrl = returnUrl }, new { act = "AllUser", cont = "User" }),Url.Route( new { @class = "a_blue" }))%></td>
                <td><%=Html.ActionLink("账变明细", "AccountDetail", Url.Route(new { Serch = new { LoginName = item.ChildName  }, ReturnUrl = returnUrl }, new { act = "AllUser", cont = "User" }),Url.Route( new { @class="a_blue"}))%></td>
                <td>
                    <% if (item.Type == (short)UserType.Member)
                       { 
                    %>     <div id='div_<%=i %>'> 
                                <label class="link" onclick="lbl_Click('<%=item.Uid %>',<%=i %>,<%=item.OnlineState!=UserOnlineState.OnLine?1:0 %>)">
                                    更改</label>
                    </div>
                    <div id='div_Hide_<%=i %>' style="display: none">
                        <%=Html.ActionLink("更改", "Chage", new { id = item.Uid, returnUrl = returnUrl }, new { @class = "a_blue" })%>
                    </div>
                    <% }
                       else 
                       { 
                    %>      <%=Html.ActionLink("更改", "Chage", new { id = item.Uid, returnUrl = returnUrl }, new { @class = "a_blue" })%>
                    <% }
                    %>
                </td>
                <td>
                    <%=Html.ActionLink("奖金", "WinMoney", new { uid = item.Uid,returnurl=Request.RawUrl }, new { @class="a_blue"})%>
                    <%=Html.ActionLink("返点", "SetWinRatio", new { uid = item.Uid,returnurl=Request.RawUrl }, new { @class="a_blue"})%>
                    <%=Html.ActionLink("查看", "Manage_Detail", new { id = item.Uid, returnUrl = returnUrl }, new { @class = "a_blue" })%>

                </td>
            </tr>
        <%
	    }
            var page = Model.PageInfo;
            if (page.PageCount>1||Request["returnUrl"]!=null)
            {
            %>
                <tr>
                    <%if (Request["returnUrl"] != null)
                      { %>
                    <td align="left"><a href='<%=Request["returnUrl"] %>' class="a_blue">返回>></a></td>
                    <%}
                      else
                      { %><td>&nbsp;</td><%} if (page.PageCount > 1)
                      {%>

                    <td colspan='9' align="center">
                        <%=Html.Pager(page.CurrPage, page.PageCount, page.SunCount, "PageInfo.CurrPage", Url.Route(new { Model.OrderByBalanceASC, Model.OrderByRegestTimeASC, Model.PageInfo, Model.Where, Model.UserID }), "PageInfo.PageCount")%>
                    </td>
                    <%}
                      else
                      { %>
                      <td colspan='9'>&nbsp;</td>
                    <%} %>
                </tr>
        <%} %>
    </table>
</div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <style type="text/css">
        .lbl{ float:left; text-align:right; width:130px;}
        h4{ margin:8px 0px; font-weight:200; font-size:12px;}
    </style>
    <script type="text/javascript">
        function lbl_Click(id, index, flag) {
            if (confirm('确定要将此会员升级为代理?')) {
                getJSON('<%=Url.Action("Chage_Json") %>', { id: id }, function (result) {
                    if (result.count > 0) {
                        $('.manage_AllUser_Table #td_' + index).text('代理');
                        $('.manage_AllUser_Table #div_' + index).hide();
                        if (flag == 1) {
                            $('.manage_AllUser_Table #div_Hide_' + index).show();
                        }
                        alert('更改成功！');
                    }
                    else {
                        alert(result.msg);
                    }
                });
            }
            return false;
        }
        function lbl_OrderBy_Click(id, value) {
            document.location.href = '<%=Url.Action("AllUser", "User", Url.Route(new { Model.UserID, Model.Where, PageInfo=new {Model.PageInfo.PageCount} }))%>&OrderBy' + id + 'ASC=' + value;
        }
    </script>
</asp:Content>
